var chip = new HTTP.Cookies;

function obliterate () {
   if ( confirm("Do you really want to wipe-out all cookies?") ) {
	  alert("Sending cookies to oblivion ...");
      chip.obliterate();
      history.go(0);
   }
   else {
      alert("Obliteration cancelled!");
   }
}

function getval () {
   var cname  = param('cname');
   var cvalue = oparam('cvalue');
   if(!cname || !cvalue) return;
   cvalue.value = chip.read(cname);
}

function setval () {
   var cname  = param('cname');
   var cvalue = param('cvalue');
   if(!cname) return;
   chip.write(cname, cvalue, '+1d');
   history.go(0);
}

function del () {
   var cname = param('cname');
   if(!cname) return;
   chip.remove(cname);
   history.go(0);
}

function param (name) {
   if(!name) return;
   var o = oparam(name);
   if (o) {
      return o.innerHTML || o.value || undefined;
   } else {
      return;
   }
}

function oparam (name) {
   if(!name) return;
   var o;
        if(document.all           ) {o = document.all[name]            }
   else if(document.getElementById) {o = document.getElementById(name) }
   else if(document.layers        ) {o = nsparam(name)                 }
   else {}
   return o;
}

function nsparam (name) {
   var o = document.layers[name];
   if (!o) {
      for(var i = 0; i < document.forms.length; i++) { // is_form()
         if(!document.forms[i]) break;
         o = eval("document.forms["+i+"]."+name);
         if(o) break;
      }
   }
   return o;
}
